package com.xiangge.zuoye.Demo2;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/3/17 17:55
 * @description 矩形类
 */
public class Rectangle {
    private double chang;
    private double kuan;

    public Rectangle(double chang, double kuan) {
        this.chang = chang;
        this.kuan = kuan;
    }

    public Rectangle() {
    }

    public double getChang() {
        return chang;
    }

    public void setChang(double chang) {
        this.chang = chang;
    }

    public double getKuan() {
        return kuan;
    }

    public void setKuan(double kuan) {
        this.kuan = kuan;
    }
    public double getArea(){
        //获取面积
        return chang*kuan;
    }
    public double getPerimeter(){
        //获取周长
        return chang*2+kuan*2;
    }
    public void getInfo(){
        System.out.println("长："+chang+"，" +
                "宽："+kuan+"，" +
                "面积："+getArea()+"，" +
                "周长："+getPerimeter());
    }


    @Override
    public String toString() {
        return "Rectangle{" +
                "chang=" + chang +
                ", kuan=" + kuan +
                '}';
    }
}
